package com.yic.module.wms.dal.mysql.producein;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.wms.dal.dataobject.producein.ProduceInDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.wms.controller.admin.producein.vo.*;

/**
 * 生产入库单 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ProduceInMapper extends BaseMapperX<ProduceInDO> {

    default PageResult<ProduceInDO> selectPage(ProduceInPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProduceInDO>()
                .eqIfPresent(ProduceInDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ProduceInDO::getMoId, reqVO.getMoId())
                .eqIfPresent(ProduceInDO::getItemWarehouseId, reqVO.getItemWarehouseId())
                .eqIfPresent(ProduceInDO::getCode, reqVO.getCode())
                .eqIfPresent(ProduceInDO::getBatchNo, reqVO.getBatchNo())
                .eqIfPresent(ProduceInDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ProduceInDO::getToErp, reqVO.getToErp())
                .betweenIfPresent(ProduceInDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProduceInDO::getId));
    }

    default List<ProduceInDO> selectList(ProduceInExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ProduceInDO>()
                .eqIfPresent(ProduceInDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ProduceInDO::getMoId, reqVO.getMoId())
                .eqIfPresent(ProduceInDO::getItemWarehouseId, reqVO.getItemWarehouseId())
                .eqIfPresent(ProduceInDO::getCode, reqVO.getCode())
                .eqIfPresent(ProduceInDO::getBatchNo, reqVO.getBatchNo())
                .eqIfPresent(ProduceInDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ProduceInDO::getToErp, reqVO.getToErp())
                .betweenIfPresent(ProduceInDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProduceInDO::getId));
    }

    default ProduceInDO selectByCode(String code) {
        return selectOne(new LambdaQueryWrapperX<ProduceInDO>()
                .eq(ProduceInDO::getCode, code));
    }
}
